package com.demo.steammanagement.service.impl;

import com.demo.steammanagement.model.vo.RedeemCodeInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.demo.steammanagement.mapper.RedeemCodeInfoMapper;
import com.demo.steammanagement.model.entity.RedeemCodeInfo;
import com.demo.steammanagement.service.RedeemCodeService;

import lombok.extern.slf4j.Slf4j;

@Service
@Slf4j
public class RedeemCodeImpl extends ServiceImpl<RedeemCodeInfoMapper, RedeemCodeInfo>
	implements RedeemCodeService{
	
	  @Autowired
	  private RedeemCodeInfoMapper redeemCodeInfoMapperMapper;
	  
	  @Override
	  public RedeemCodeInfo getRedeemCodeByCode(String code) {
	    LambdaQueryWrapper<RedeemCodeInfo> queryWrapper = new LambdaQueryWrapper<>();
	    queryWrapper.eq(RedeemCodeInfo::getRedeemCode, code);
	    queryWrapper.last("limit 1");
	    RedeemCodeInfo redeemCodeInfo = redeemCodeInfoMapperMapper.selectOne(queryWrapper);
	    return redeemCodeInfo;
	  }

  @Override
  public void updateRedeemCode(RedeemCodeInfo redeemCodeInfo) {
	  redeemCodeInfoMapperMapper.updateRedeemCode(redeemCodeInfo);
  }
}
